InstanceID=$(ec2-run-instances ami-6ac2a85a -t t1.micro -k key-pair -g SG_oregon|grep INSTANCE| awk {'print $2'})

flag=1
count=0
while [ $flag -eq 1 ]
do
	if [ "$InstanceID" = "" ]; then
		exit 
	fi;
	echo trying to find the status of $InstanceID
	Status=$(ec2-describe-instance-status $InstanceID | grep INSTANCE | awk {'print $6'})
	echo $count: status of $InstanceID is $Status
	if [ "$Status" = "ok" ]; then 
    	echo OK
    	flag=0
	else
    	echo NOKAY
    	sleep 10
	fi;
 	count=$(($count+10))
done
User=ubuntu
DNS=$(ec2-describe-instances  $InstanceID | grep INSTANCE | awk {'print $4'})
(cat lunchCommands | ssh -oStrictHostKeyChecking=no -i key-pair.pem $User@$DNS sh)
